package com.zmkj.cn.sys.controller;


import com.zmkj.cn.sys.dto.SysLogDto;
import com.zmkj.cn.sys.entity.SysLog;
import com.zmkj.cn.sys.service.ISysLogService;
import com.zmkj.cn.sys.vo.input.SysLogInputVo;
import com.zmkj.cn.sys.vo.query.SysLogQueryVo;
import com.zmkj.cn.comm.vo.PageInput;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "系统日志记录表接口")
@RestController
@RequestMapping("/sysLog")

public class SysLogController {

    @Autowired
    private ISysLogService sysLogService;

    /**
     * 新增修改系统日志记录表
     * 
     */
    @RequestMapping("/saveOrUpdate")
    @ApiOperation(value = "新增系统日志记录表", httpMethod = "POST", notes = "新增系统日志记录表")
    @ApiResponses({ @ApiResponse(code = 200, message = "新增系统日志记录表成功")})
    public Object save(@ModelAttribute SysLogInputVo sysLogInputVo){
        SysLog sysLog= sysLogService.saveOrUpdate(sysLogInputVo);
        return sysLog.getId();
    }



    /**
     * 删除系统日志记录表
     * 
     */
    @RequestMapping("/delete")
    @ApiOperation(value = "删除系统日志记录表", httpMethod = "POST", notes = "删除系统日志记录表")
    @ApiResponses({ @ApiResponse(code = 200, message = "删除系统日志记录表成功") })
    public Object delete(Integer id){
        sysLogService.deleteByPrimary(id);
        return  null;
    }


    /**
     * 获取系统日志记录表
     * 
     */
    @RequestMapping("/get")
    @ApiOperation(value = "获取系统日志记录表", httpMethod = "POST", notes = "获取系统日志记录表")
    @ApiResponses({ @ApiResponse(code = 200, message = "获取系统日志记录表成功") })
    public Object get(Integer id){
        SysLogDto sysLogDto=sysLogService.getDtoByPrimary(id);
        return  sysLogDto;
    }

    /**
     * 获取系统日志记录表分页
     * @param pageInput 分页参数
     * @param sysLogQueryVo 查询参数对象
     * 
     */
    @RequestMapping("/getPage")
    @ApiOperation(value = "获取系统日志记录表分页列表", httpMethod = "POST", notes = "获取系统日志记录表分页列表")
    @ApiResponses({ @ApiResponse(code = 200, message = "获取系统日志记录表分页列表成功") })
    public  Object queryPage(@ModelAttribute PageInput pageInput, @ModelAttribute SysLogQueryVo sysLogQueryVo){
        return sysLogService.getPage(pageInput,sysLogQueryVo);
    }

}
